﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace HigLabo.Net.Twitter
{
    public partial class TwitterClient
    {
        /// <summary>
        /// 
        /// </summary>
        /// <param name="callback"></param>
        public void GetAllLists(Action<ListCollection> callback)
        {
            this.GetAllLists(null, callback);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void GetAllLists(GetAllListsCommand command, Action<ListCollection> callback)
        {
            this.GetResultText(TwitterApiUrl.Version1_1.Lists.GetAllListsUrl, command
                , json => callback(new ListCollection(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void GetListsStatuses(GetListsStatusesCommand command, Action<StatusCollection> callback)
        {
            this.GetResultText(TwitterApiUrl.Version1_1.Lists.GetListsStatusesUrl, command
                , json => callback(new StatusCollection(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void DestroyListMembers(DestroyListsMembersCommand command, Action<User> callback)
        {
            this.GetResultText(HttpMethodName.Post, TwitterApiUrl.Version1_1.Lists.DestroyListsMembersUrl, command
                , json => callback(new User(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void GetListsMemberships(GetListsMembershipsCommand command, Action<Memberships> callback)
        {
            this.GetResultText(TwitterApiUrl.Version1_1.Lists.GetListsMembershipsUrl, command
                , json => callback(new Memberships(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="callback"></param>
        public void GetListsSubscribers(Action<FriendsUser> callback)
        {
            this.GetListsSubscribers(null as GetListsSubscribersCommand, callback);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void GetListsSubscribers(GetListsSubscribersCommand command, Action<FriendsUser> callback)
        {
            this.GetResultText(TwitterApiUrl.Version1_1.Lists.GetListsSubscribersUrl, command
                , json => callback(new FriendsUser(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void CreateListsSubscribers(CreateListsSubscribersCommand command, Action<List> callback)
        {
            this.GetResultText(HttpMethodName.Post, TwitterApiUrl.Version1_1.Lists.CreateListsSubscribersUrl, command
                , json => callback(new List(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void ShowListsSubscribers(ShowListsSubscribers command, Action<User> callback)
        {
            this.GetResultText(TwitterApiUrl.Version1_1.Lists.ShowListsSubscribersUrl, command
                , json => callback(new User(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void DestroyListsSubscribers(DestroyListsSubscribersCommand command, Action<User> callback)
        {
            this.GetResultText(HttpMethodName.Post, TwitterApiUrl.Version1_1.Lists.DestroyListsSubscribersUrl, command
                , json => callback(new User(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="values"></param>
        /// <param name="callback"></param>
        public void CreateAllListsMembers(Int64[] values, Action<FriendshipCollection> callback)
        {
            StringBuilder sb = new StringBuilder(256);
            for (int i = 0; i < values.Length; i++)
            {
                sb.Append(values[i]);
                if (i < values.Length - 1)
                {
                    sb.Append(",");
                }
            }
            var cm = new CreateAllListsMembersCommand();
            cm.UserID = sb.ToString();
            this.CreateAllListsMembers(cm, callback);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="values"></param>
        /// <param name="callback"></param>
        public void CreateAllListsMembers(String[] values, Action<FriendshipCollection> callback)
        {
            StringBuilder sb = new StringBuilder(256);
            for (int i = 0; i < values.Length; i++)
            {
                sb.Append(values[i]);
                if (i < values.Length - 1)
                {
                    sb.Append(",");
                }
            }
            var cm = new CreateAllListsMembersCommand();
            cm.ScreenName = sb.ToString();
            this.CreateAllListsMembers(cm, callback);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void CreateAllListsMembers(CreateAllListsMembersCommand command, Action<FriendshipCollection> callback)
        {
            this.GetResultText(HttpMethodName.Post, TwitterApiUrl.Version1_1.Lists.CreateAllListsMembersUrl, command
                , json => callback(new FriendshipCollection(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void ShowListsMembers(ShowListsMembersCommand command, Action<User> callback)
        {
            this.GetResultText(TwitterApiUrl.Version1_1.Lists.ShowListsMembersUrl, command
                , json => callback(new User(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void GetListsMembers(GetListsMembersCommand command, Action<FriendsUser> callback)
        {
            this.GetResultText(TwitterApiUrl.Version1_1.Lists.GetListsMembersUrl, command
                , json => callback(new FriendsUser(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void CreateListsMembers(CreateListsMembersCommand command, Action<User> callback)
        {
            this.GetResultText(HttpMethodName.Post, TwitterApiUrl.Version1_1.Lists.CreateListsMembersUrl, command
                , json => callback(new User(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void DestroyLists(DestroyListsCommnad command, Action<List> callback)
        {
            this.GetResultText(HttpMethodName.Post, TwitterApiUrl.Version1_1.Lists.DestroyListsUrl, command
                , json => callback(new List(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void UpdateLists(UpdateListsCommand command, Action<List> callback)
        {
            this.GetResultText(HttpMethodName.Post, TwitterApiUrl.Version1_1.Lists.UdateListsUrl, command
                , json => callback(new List(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void CreateLists(CreateListsCommnad command, Action<List> callback)
        {
            this.GetResultText(HttpMethodName.Post, TwitterApiUrl.Version1_1.Lists.CreateListsUrl, command
                , json => callback(new List(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void GetLists(GetListsCommand command, Action<Memberships> callback)
        {
            this.GetResultText(TwitterApiUrl.Version1_1.Lists.GetListsUrl, command
                , json => callback(new Memberships(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void ShowLists(ShowListsCommnad command, Action<List> callback)
        {
            this.GetResultText(TwitterApiUrl.Version1_1.Lists.ShowListsUrl, command
                , json => callback(new List(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void GetListsSubscriptions(GetListsSubscriptionsCommand command, Action<Memberships> callback)
        {
            this.GetResultText(TwitterApiUrl.Version1_1.Lists.GetListsSubscriptionsUrl, command
                , json => callback(new Memberships(json)));
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="values"></param>
        /// <param name="callback"></param>
        public void DestroyAllListsMembers(Int64[] values, Action<FriendshipCollection> callback)
        {
            StringBuilder sb = new StringBuilder(256);
            for (int i = 0; i < values.Length; i++)
            {
                sb.Append(values[i]);
                if (i < values.Length - 1)
                {
                    sb.Append(",");
                }
            }
            var cm = new DestroyAllListsMembersCommand();
            cm.UserID = sb.ToString();
            this.DestroyAllListsMembers(cm, callback);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="values"></param>
        /// <param name="callback"></param>
        public void DestroyAllListsMembers(String[] values, Action<FriendshipCollection> callback)
        {
            StringBuilder sb = new StringBuilder(256);
            for (int i = 0; i < values.Length; i++)
            {
                sb.Append(values[i]);
                if (i < values.Length - 1)
                {
                    sb.Append(",");
                }
            }
            var cm = new DestroyAllListsMembersCommand();
            cm.ScreenName = sb.ToString();
            this.DestroyAllListsMembers(cm, callback);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="command"></param>
        /// <param name="callback"></param>
        public void DestroyAllListsMembers(DestroyAllListsMembersCommand command, Action<FriendshipCollection> callback)
        {
            this.GetResultText(HttpMethodName.Post, TwitterApiUrl.Version1_1.Lists.DestroyAllListsMembersUrl, command
                , json => callback(new FriendshipCollection(json)));
        }
    }
}
